﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.ServiceModel;
using Client.Service;
using ModelLayer;

namespace Client
{
    public partial class CinemaMainMenu : Form
    {
        private IShow showService;
        private ICities cityService;
        private IShow seatService;
        //private BookingService bookingService;
        private SearchCustomerGUI scGui;
        private ShowTypesGUI stGui;
        //private ConfirmReservationGUI crGui;
        //private SeatReservation srGui;

        public CinemaMainMenu()
        {
            InitializeComponent();
            showService = new ShowClient("BasicHttpBinding_IShow");             //Interfacenavnet skal angives, når der er mere end et tilknyttet en service
            cityService = new CitiesClient("BasicHttpBinding_ICities");         //bortset fra hvis der ikke kan være tvivl. pt. har servicen 2 interfaces. Det ene er allerede angivet.
            custService = new CustomerClient("BasicHttpBinding_ICustomer");
            //bookingService = new BookingService();
            //scGui = new SearchCustomerGUI();
            //stGui = new ShowTypesGUI();
            //fillSeats();
            //srGui = new SeatReservation();
            panelCustomer.Hide();
            panelShowTypes.Hide();
            pnlBookSeat.Hide();
            panelConfirmReservation.Hide();


            pictureBoxFrontPic.ImageLocation = "http://www.mynetimages.com/648ece0b80.jpg";
            DoSomething();
            //sbGui = new SeatBookingGUI();
        }

        private void hovedMenuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panelFront.Show();
            panelFront.BringToFront();
        }

        private void kundeMenuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panelCustomer.Show();
            panelCustomer.BringToFront();
        }

        private void showsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panelShowTypes.Show();
            panelShowTypes.BringToFront();
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void seatBookMenuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //srGui.Show();
            //srGui.Activate();
        }


        #region BookSeat

        public void DoSomething()
        {

            showService = new ShowClient("BasicHttpBinding_IShow");
            seatService = new ShowClient("BasicHttpBinding_IShow");
            Show show = showService.GetShow(8);
            //List<Show> shows = new List<Show>(showService.GetAllShows());

            cbShow.Text = show.Type.Title;
            cbDate.Text = show.Date.Date.ToLongDateString();
            cbTime.Text = show.Date.TimeOfDay.ToString();
            //lblLokale.Text = show.Room.RoomNumber.ToString();
            lblPrice1.Text = "DKR:  " + show.Prices[1].TicketPrice.ToString();
            lblPrice2.Text = "DKR:  " + show.Prices[0].TicketPrice.ToString();
            lblPrice3.Text = "DKR:  " + show.Prices[2].TicketPrice.ToString();
            //List<Show> shows = new List<Show>().showService.GetAllShows();
            //List<Show> shows = new List<Show>(showService.GetAllShows());
            //cbShow.Items.Add(
            //showService.GetAllShows()
            getAll();

        }




        public void getAll()
        {
            List<Show> shows = new List<Show>(showService.GetAllShows());

            for (int i = 0; i < shows.Count(); i++)
            {
                Show s = shows[i];
                cbShow.Items.Add(s.Type.Title.ToString());


            }
        }
        //public void fillSeats()
        //{
        //    ShowRoom showroom = showService.GetShowRoomOnShowId(1);
        //    A1.Text = "A-1" + showroom.Seats[0].SeatId.ToString();
        //}




        #endregion

        private void bekræftToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panelConfirmReservation.Show();
            panelConfirmReservation.BringToFront();

            DisplayCustomerName();
            DisplayCustomerAddress();
            DisplayCustomerCity();
            DisplayCustomerPhoneNo();
            DisplayCustomerEmail();

            DisplayShowName();
            DisplayShowDate();
            DisplayShowTime();
            DisplayScreenName();
            DisplayNoOfSeatsBooked();

        }

        #region Confirm reservation Methods
        private void DisplayCustomerName()
        {
            Customer cust = custService.GetCustomerByPhoneNo("11223344");
            custNameLabel.Text = cust.FName + " " + cust.LName;
        }

        private void DisplayCustomerAddress()
        {
            Customer cust = custService.GetCustomerByPhoneNo("11223344");
            custAddressLabel.Text = cust.Address;
        }

        private void DisplayCustomerCity()
        {
            Customer cust = custService.GetCustomerByPhoneNo("11223344");
            custPostalCodeLabel.Text = cust.PostalCode.ToString();
            custCityNameLabel.Text = cust.City;
        }

        private void DisplayCustomerPhoneNo()
        {
            Customer cust = custService.GetCustomerByPhoneNo("11223344");
            custPhoneNoLabel.Text = cust.PhoneNo.ToString();
        }

        private void DisplayCustomerEmail()
        {
            Customer cust = custService.GetCustomerByPhoneNo("11223344");
            custEmailLabel.Text = cust.Email.ToString();
        }


        private void DisplayShowName()
        {
            Show show = showService.GetShow(1);
            chosenShowNameLabel.Text = show.Type.Title;
        }

        //TODO: Viser DateTime, den bør kun vise dato
        private void DisplayShowDate()
        {
            Show show = showService.GetShow(1);
            chosenShowDateLabel.Text = show.Date.ToString();
        }

        //TODO: Viser DateTime, den bør kun vise tid
        private void DisplayShowTime()
        {
            Show show = showService.GetShow(1);
            chosenShowTimeLabel.Text = show.Date.ToString();
        }

        private void DisplayScreenName()
        {
            Show show = showService.GetShow(1);
            chosenShowRoomLabel.Text = show.Room.RoomNumber.ToString();
        }

        private void DisplayNoOfSeatsBooked()
        {
            //TODO: Find en løsning
            chosenNumberOfSeatsLabel.Text = "Metoden er fucked op";
        }
        #endregion




    }
}
